package cn.ddd.linktran.application.executor.command;

import cn.ddd.linktran.client.dto.cmd.AppAccessRegisterCmd;
import cn.ddd.linktran.client.dto.data.AppAccessDTO;
import cn.ddd.linktran.domain.domainservice.token.TokenDomainService;
import com.alibaba.cola.dto.SingleResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class AppAccessRegisterCmdExe {
    @Autowired
    private TokenDomainService tokenDomainService;

    public SingleResponse<AppAccessDTO> execute(AppAccessRegisterCmd appAccessRegisterCmd){
        String appSecret = tokenDomainService.registerAppId(appAccessRegisterCmd.getAppId());

        AppAccessDTO appAccessDTO = new AppAccessDTO();
        appAccessDTO.setAppId(appAccessRegisterCmd.getAppId());
        appAccessDTO.setAppSecret(appSecret);
        return SingleResponse.of(appAccessDTO);
    }
}
